import Vue from "vue";
// 引入day.js
import dayjs from "dayjs";
// 引入中文语言包
import "dayjs/locale/zh-cn";
// 引入relativeTime
import relativeTime from "dayjs/plugin/relativeTime";

dayjs.extend(relativeTime);
// 配置中文语言包
dayjs.locale("zh-cn");
// 过滤器
Vue.filter("dateTime", (value, format = "YYYY-MM-DD") => {
  return dayjs(value).format(format);
});
Vue.filter("playtime", (value, format = "mm:ss") => {
  return dayjs(value).format(format);
});
Vue.filter("Time", (value, format = "YYYY-MM-DD HH:mm:ss") => {
  return dayjs(value).format(format);
});
Vue.filter("UpdateTime", (value, format = "MM" + "月" + "DD" + "日") => {
  return dayjs(value).format(format);
});

Vue.filter("playCount", count => {
  if (count >= 100000) {
    return parseInt(count / 10000) + "万";
  } else {
    return count;
  }
});
export default dayjs;
